﻿@model IEnumerable<OpenIdentity>
@{
    ViewBag.Title = "MyOpenIDs";
    Layout = "~/Views/Shared/_Dashboard.cshtml";
}
@UIHelper.ImageTitle("OpenID", Html.Global("OpenID_Desc"), "~/content/images/icon_openid_48.png")
@UIHelper.SectionHeader(Html.Global("OpenID_AddOpenID"))
@using (Html.BeginForm())
{
    <table>
        @if (ViewBag.Error != null)
        {
            <tr>
                <td style="padding: 10px;" class="ui-state-error">@ViewBag.Error
                </td>
            </tr>
        }
        <tr>
            <td>
                Url:
            </td>
            <td>@Ajax.Dna().TextBox("OpenID").Width(300).GetHtml()
            </td>
            <td>@Ajax.Dna().Button().LocText("RES_ADD").Submit().GetHtml()
            </td>
        </tr>
    </table>
}
@{
    if (Model.Count() > 0)
    {
    <table cellpadding="5">
        @foreach (var passport in Model)
        {
            <tr id="openID_@(passport.ID)">
                <td>@passport.UserId
                </td>
                <td>
                    @(Ajax.Dna().Button()
                    .ChangeType(ButtonTypes.LinkButton)
                .Click("_deleteUrl(" + passport.ID.ToString() + ",\"" + passport.UserId + "\");")
                    .ImageIcons(Url.Content("~/content/images/icon_delete_16.png"))
                    .LocText("RES_DELETE")
                    .GetHtml())
                </td>
            </tr>
        }
    </table>
    }
}
<script type="text/javascript">
    function _deleteUrl(_id,_openID) {
        $.ajax({
            url: "@Url.Action("DeleteOpenID", "Account", new { Area = "" })",
            method:"POST",
            data: { openID: _openID },
            success: function () {
                $("#openID_" + _id).remove();
            }
        });
    }
</script>
